package com.sea.app.module.process.controller;

import com.sea.app.common.Entity.http.Response;
import com.sea.app.module.process.controller.param.StartProcessRequest;
import com.sea.app.module.process.controller.result.ProcessInstanceResult;
import com.sea.app.module.process.domain.service.ActivitiProcessService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by 31417 on 2017/5/9.
 */
@RestController
@RequestMapping("/process")
public class ProcessController {

    @Autowired
    ActivitiProcessService activitiProcessService;

    @RequestMapping("start")
    public Object start(StartProcessRequest request){
        ProcessInstance instance = activitiProcessService.startProcess(request.getUserId(),
                request.getProcessDefinitionId(),
                request.getBusinessKey(),
                request.getParam());

        return Response.OK.body(new ProcessInstanceResult(instance));
    }

}
